﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;

namespace MessengerBot
{
    /// <summary>
    /// This class holds extension methods for <see cref="ILogger"/>.
    /// </summary>
    public static class LoggerExtensions
    {
        /// <summary>
        /// Logs a formatted message to the specified <paramref name="logger"/>.
        /// </summary>
        /// <param name="logger">
        /// The <see cref="ILogger"/> to log to.
        /// </param>
        /// <param name="format">
        /// A composite format string.
        /// </param>
        /// <param name="arguments">
        /// An object array that contains zero or more objects to format.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="logger"/> is <c>null</c>.</para>
        /// <para>- or -</para>
        /// <para><paramref name="format"/> is <c>null</c>.</para>
        /// <para>- or -</para>
        /// <para><paramref name="arguments"/> is <c>null</c>.</para>
        /// </exception>
        public static void Log(this ILogger logger, string format, params object[] arguments)
        {
            if (logger == null)
                throw new ArgumentNullException("logger");
            if (format == null)
                throw new ArgumentNullException("format");
            if (arguments == null)
                throw new ArgumentNullException("arguments");

            logger.Log(string.Format(CultureInfo.InvariantCulture, format, arguments));
        }
    }
}